
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YCKOKO
 * Date: 2022-11-24
 * Time: 10:38
 */
public class MyBinaryTree {
    static class TreeNode{
        public int val;
        public TreeNode left;
        public TreeNode right;

        public TreeNode(int val) {
            this.val = val;
        }
    }
    public static TreeNode createTree(){
        TreeNode A = new TreeNode('A');
        TreeNode B = new TreeNode('B');
        TreeNode C = new TreeNode('C');
        TreeNode D = new TreeNode('D');
        TreeNode E = new TreeNode('E');
        TreeNode F = new TreeNode('F');
        TreeNode G = new TreeNode('G');
        TreeNode H = new TreeNode('H');

        A.left = B;
        A.right = C;
        B.left = D;
        B.right = E;
        C.right = F;
        E.left = G;
        F.left = H;

        return A;
    }


    // 获取树中节点的个数
    //法1：对二叉树的左子树和右子树进行分别遍历
    //法2：使用递归思想
    static int NodeSize = 0;
    int size1(TreeNode root){
        if(root == null){
            return 0;
        }
        NodeSize++;
        size1(root.left);
        size1(root.right);
        return NodeSize;
    }

    int size(TreeNode root){
        if(root == null){
            return 0;
        }
        return size(root.left)+size(root.right)+1;
    }

    // 获取叶子节点的个数
    int getLeafNodeCount(TreeNode root){
        if(root ==null){
            return 0;
        }
        if(root.left==null && root.right==null){
            return 1;
        }
        return  getLeafNodeCount(root.left)+getLeafNodeCount(root.right);
    }
/**
    int getLeafNodeCount(TreeNode root){
        if(root ==null){
            return 0;
        }
        if(root.left==null && root.right==null){
            count++;
        }
        getLeafNodeCount(root.left);
        getLeafNodeCount(root.right);
        return count;
    }
    */

    // 子问题思路-求叶子结点个数
    // 获取第K层节点的个数
    int getKLevelNodeCount(TreeNode root){
        return 0;
    }
    // 获取二叉树的高度
    int getHeight(TreeNode root){
        return 0;
    }
    // 检测值为value的元素是否存在
   boolean find(TreeNode root, int val){
        return false;
    }
    //层序遍历
    void levelOrder(TreeNode root){

    }
    // 判断一棵树是不是完全二叉树
    boolean isCompleteTree(TreeNode root){
        return false;
    }
}
